﻿namespace LinesOfAction.Converters
{
    using System;
    using System.Globalization;
    using System.Windows.Data;
    using System.Windows.Markup;
    using System.Windows.Media;
    using Enumerations;

    public class PlayerToColorConverter : MarkupExtension, IValueConverter
    {
        public PlayerToColorConverter()
        {
            
        }

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (Players) value == Players.Player1 ? Brushes.White : Brushes.DimGray;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Equals(value, Brushes.White) ? Players.Player1 : Players.Player2;
        }

        #endregion

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }
    }
}